package com.lee.main;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author
 * @create 2018-01-30 18:40
 **/
public class TestPostJson {

    public static void main(String [] args)
    {

      String url1 = "http://192.168.100.3:9080//rest/read/msg/getsyscfg/1?cfgkey=useraccount.encrept.resist.flag";
      String url2 = "http://192.168.100.173:8090//pcc/rest/sns/profile/update/7/90764623282/s1CvLghlTsm";
//      URL url = null;
//      HttpURLConnection connection = null;
      String params = "{\"iconurl\":\"91342372541_01261816462.png\",\"avatar_m\":\"91342372541_01261816462.png\",\"avatar_l\":\"91342372541_01261816462.png\",\"avatar_s\":\"91342372541_01261816462.png\",\"userid\":\"91342372541\",\"nickname\":\"梦幻西游\"}";
//      String params1 = "flag=1";
//      int code = 0;
//      try {
//
//        Long t1 = System.currentTimeMillis();
//
//        url = new URL(url2);
//        connection = (HttpURLConnection) url.openConnection();
//        connection.setRequestProperty("Content-Type","application/json;charset=UTF-8");
//        connection.setRequestProperty("accept","application/json");
//        connection.setRequestMethod("GET");
//        connection.setDoOutput(true);
//
////        connection.setRequestProperty("Content-Length", String.valueOf(params.getBytes().length));
////        OutputStream outputStream = connection.getOutputStream();
////        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
////        outputStream.write(params.getBytes());
////        outputStream.flush();
////        outputStream.close();
//
//        code = connection.getResponseCode();
//
//        System.out.println("*******************************************");
//        System.out.println("-----------------"+code+"-----------------");
//        System.out.println("*******************************************");
//
//
//        Long t2= System.currentTimeMillis();
//
//        System.out.println( t2- t1 );
//
//      } catch (MalformedURLException e) {
//        e.printStackTrace();
//      } catch (IOException e) {
//        e.printStackTrace();
//      }

      try {
        System.out.println(TestOkHttpPost.getInstance().httpPost(url2,params));
      } catch (IOException e) {
        e.printStackTrace();
      }


    }

}
